<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0026)http://laterthis.com/login -->
<HTML lang=en xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
	<HEAD>
		<TITLE></TITLE>
		<script src="js/prototype.js"></script>
		<META http-equiv=content-type content=text/html;charset=UTF-8>
		<LINK media=screen href="css/style.css" type=text/css rel=stylesheet>
		<style>
.code {
	background-image: url(code.jpg);
	font-family: Arial;
	font-style: italic;
	color: Red;
	border: 0;
	padding: 2px 3px;
	letter-spacing: 3px;
	font-weight: bolder;
}

.unchanged {
	border: 0;
</style>
		<script language="javascript" type="text/javascript">
			function callServer() {
			  var username = document.getElementById("login").value;
			  if ((username == null) || (username == "")) {
			  	document.getElementById("prompt").innerHTML="用户名不能为空!";
			  	return;
			  }else{
			  	document.getElementById("prompt").innerHTML="";
			  } 
			}
			
			function callValidate(){
				var password= document.getElementById("password").value;
				if((password==null)||(password=="")){
					document.getElementById("prompt2").innerHTML="密码不能为空!";
			  		return;				
				}else{
					document.getElementById("prompt2").innerHTML="";
				}
				
			}
			
			var code; //在全局 定义验证码  
			function createCode() {
				code = "";
				var codeLength = 4;//验证码的长度  
				var checkCode = document.getElementById("checkCode");
				var selectChar = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");//所有候选组成验证码的字符，当然也可以用中文的  
				for (var i = 0; i < codeLength; i++) {
					var charIndex = Math.floor(Math.random() * 36);
					code += selectChar[charIndex];
				}  
			//       alert(code);  
				if (checkCode) {
					checkCode.className = "code";
					checkCode.value = code;
				}
			}
			 function validate()
			     {  
			       var inputCode = document.getElementById("authcode").value;  
			       if(inputCode.length <=0)  
			       {  
			           alert("请输入验证码！");
			           document.login.authcode.focus();
			           return false;   
			       }  
			       else if(inputCode != code )  
			       {  
			          alert("验证码输入错误！");  
			          createCode();//刷新验证码
			          document.login.authcode.focus();
			          return false;  
			       }  
			       else  
			       {  
			         return true;  
			       }     
			    }
			    	      
		</script>
	</HEAD>
	<body onload="createCode()">
		<DIV id=page-content>
			<DIV id=login-page>
				<form name="login" action="login" method="post"
					onsubmit="return validate()">
					<DIV id=normal-login>
						<P>
							<LABEL for=login>
								帐号:
							</LABEL>
							<BR>
							<input id="login" type="text" name="username"
								onChange="callServer();" />
						</P>
						<p>
							<font color="red" size="2"><span id="prompt"></span> </font>
						</p>
						
						<P>
							<LABEL for=password>
								密码:
							</LABEL>
							<BR>
							<input id="password" type="password" name="password" onChange="callValidate();"/>
						</P>
						<p>
							<font color="red" size="2"><span id="prompt2"></span></font>
						</p>
				
						<p>
							<input type="text" onclick="createCode()" readonly="readonly"
								id="checkCode" class="unchanged" style="width: 80px" />
						</p>
						<p>
							<input style="color:#ccc" type="text" id="authcode" name="authcode"
								value="请输入上方的数字或字母..."
								onFocus="if (this.value == '请输入上方的数字或字母...') {this.value = '';};"
								onBlur="if (this.value == '') {this.value = '请输入上方的数字或字母...';};" />
						</p>
					</DIV>
					<P>
						<input class="button" type="submit" value="登陆" name="commit" />
						<A class=new_password href="#">返回首页</A>
					</P>
				</form>
			</DIV>
		</DIV>
	</body>
</HTML>

